package org.datastreamapi.transform

import org.FlinkStreamApp
import org.apache.flink.streaming.api.scala._

/**
 * description ：转换-keyby
 * author      ：剧情再美终是戏 
 * mail        : 13286520398@163.com
 * date        ：Created in 2020/2/21 19:39
 * modified By ：
 * version:    : 1.0
 */
object KeyBy extends FlinkStreamApp {

  override def doSomeThing(environment: StreamExecutionEnvironment) = {
    // 创建数据
    val source = environment.fromElements((1, 11), (1, 11), (2, 22), (3, 33))

    // 转换
    val keyBy: KeyedStream[Tuple2[Int, Int], Int] = source.keyBy(_._1)

    // 滚动聚合 sum min max minby maxby
    keyBy.sum(1).print
  }
}
